﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace NetWork_Geometry
{
    class NewWork
    {
        #region 构造器
        public NewWork()
        {
            dict = new Dictionary<string, List<string>>();
            this.readDataFromFile();
        }
        #endregion

        #region 字段
        Dictionary<string, List<string>> dict;
        #endregion

        #region 方法
        public void showNetworkTopologyInfo()
        {
            foreach (var item in this.dict)
            {
                Console.WriteLine("key:{0}", item.Key);
                Console.Write("Values:\t");
                foreach (var lineID in item.Value)
                {
                    Console.Write(lineID + "\t");
                }
                Console.WriteLine();
            }
        }

        public void readDataFromFile()
        {
            string[] allLinesArray;
            try
            {
                allLinesArray = File.ReadAllLines("PROJData\\NetworkTopology.txt");

                foreach (string data in allLinesArray)
                {
                    string[] dataArray = data.Split('\t');
                    string pointName = dataArray[0];
                    List<string> IDList = new List<string>();
                    string[] lineIDsStrArray = dataArray[1].Split(',');
                    foreach (string lineIDStr in lineIDsStrArray)
                    {
                        IDList.Add(lineIDStr);
                    }
                    dict.Add(pointName, IDList);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        } 
        #endregion
    }
}
